<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>检化验项目管理</title>
    <link rel="stylesheet" href="http://static-online.zhaogangtest.com/publicresource/css/bootstrap-table.css">
    <link rel="stylesheet" href="../../../resources/public/css/iconfont.min.css">
    <link rel="stylesheet" href="../../../resources/public/css/table.css">
    <link rel="stylesheet" href="../../../resources/public/css/scmstrap.css">
</head>

<body>
    <div class="leftside-sub">
        <div class="leftside-subTitle">品类</div>
        <div class="leftside-subinner">
            <div class="radio-list">
                <ul>
                    <li>
                        <label class="mycheckradio">
                            <em></em>中厚板
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>中厚板
                        </label>
                    </li>

                </ul>
                <div class="radio-listAction">
                    <button class="scm-btn blue btn-addKind">
                        <i class="anticon icon-plus"></i>添加</button>
                    <button class="scm-btn btn-deleteKind">
                        <i class="anticon icon-delete"></i>删除</button>
                </div>
            </div>

        </div>
    </div>
    <div class="main main-sub">
        <!-- 条件区域 -->
        <div class="form-list">
            <div class="group">
                <label>检化验项</label>
                <div class="scm-input-wrap">
                    <input type="text" class="scm-input" placeholder="">
                </div>
            </div>
            <div class="group group-select">
                <label>状态</label>
                <div class='selectshow selectshowAction scm-input-wrap'>
                    <input type="text" class="scm-input hand" readonly="" placeholder="全部">
                </div>
                <ul class="select" style="display: none;">
                    <li>全部</li>
                    <li>活跃</li>
                    <li>睡眠</li>
                </ul>
            </div>

        </div>
        <!-- 按钮 -->
        <div class="operation">
            <div class="conditionbtn">
                <button class="scm-btn blue">
                    <i class="anticon icon-search1"></i>查询</button>
                <button class="scm-btn resetBtn">
                    <i class="anticon icon-delete"></i>重置</button>
            </div>
            <!-- 按钮组 -->
            <div class="scm-btn-group fr">

                <button class="scm-btn btn-addName">
                    <i class="anticon icon-plus"></i>添加</button>
                <button class="scm-btn">
                    <i class="anticon icon-edit1"></i>修改</button>
                <button class="scm-btn">
                    <i class="anticon icon-close"></i>废弃</button>
            </div>
        </div>
        <div class="box-table box-tableTr">
            <table class="table table-condensed" id="table-dictionary"></table>
        </div>
    </div>
    
    <!-- 添加品名 -->
    <div class="layer-addName" style="display: none">
        <form class="hascheck" role="form">
            <div class="form-list  nofloat">
                <div class="group form-group">
                    <label>显示名称</label>
                    <div class="input-parent">
                        <input type="text" class="scm-input form-control">
                    </div>
                </div>
                <div class="group form-group">
                    <label>字段名称</label>
                    <div class="input-parent">
                        <input type="text" class="scm-input form-control">
                    </div>
                </div>

                <div class="group form-group">
                    <label>字段类型</label>
                    <div class="group-select">
                        <div class="selectshow selectshowAction scm-input-wrap">
                            <input type="text" class="scm-input hand" readonly="" placeholder="整数">
                        </div>
                        <ul class="select nowidth" style="display: none;">
                            <li>VIP</li>
                            <li>优质</li>
                        </ul>
                    </div>
                </div>
                <div class="group form-group">
                    <label>精度</label>
                    <div class="input-parent">
                        <input type="text" class="scm-input form-control">
                    </div>
                </div>
                
            </div>
        </form>
    </div>
     <!-- 添加种类 -->
     <div class="layer-addKind" style="display: none">
            <form class="hascheck" role="form">
                <div class="form-list nofloat">
                    <div class="group form-group">
                        <label>分类名称</label>
                        <div class="input-parent">
                            <input type="text" class="scm-input form-control">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    <script src="http://static-online.zhaogangtest.com/publicresource/js/require.js"></script>
    <script>
        require.config({
            paths: {
                "jquery": "../../../resources/public/js/jquery.min",
                "bootstrap": 'http://static-online.zhaogangtest.com/publicresource/js/bootstrap.min',
                "bootstrap-table": "../../../resources/public/js/bootstrap-table",
                "layer": "http://static-online.zhaogangtest.com/publicresource/control/layer/layer.min",
                "public": "../../../resources/public/js/public",
                "chinese": "../../../resources/public/js/chinese",
            },
            shim: {
                "jquery": {
                    exports: ['jQuery', '$']
                },
                "bootstrap": {
                    deps: ["jquery"]
                },
                "bootstrap-table": {
                    deps: ["jquery", "bootstrap"]
                },
                "layer": {
                    deps: ["jquery"],
                    exports: "layer"
                },
                "public": {
                    deps: ["jquery", "bootstrap-table"]
                },

                "chinese": {
                    deps: ["jquery", "bootstrap-table"],
                },

            }
        });
        require(["public", "layer", "chinese"], function () {
            layer.config({
                path: 'http://static-online.zhaogangtest.com/publicresource/control/layer/'
            });
            $(function () {
                var page = {
                    $table: $('#table-dictionary'),
                    init: function () {
                        this.bootstrapTable();
                        this.fn_layer();
                        this.fn_getTrData();

                        $(window).resize(function () {
                            page.$table.bootstrapTable('resetView', {
                                height: page.getHeight()
                            });
                        });
                    },

                    fn_layer: function () {
                          // 添加品类
                          $(document).on("click", ".btn-addKind", function () {
                            var index = layer.open({
                                type: 1, //page层
                                area: ['560px', ''],
                                title: '添加分类',
                                shadeClose: false,
                                btn: ['保存', '取消'],
                                shade: 0.01, //遮罩透明度
                                moveType: 1, //拖拽风格，0是默认，1是传统拖动
                                shift: -1, //0-6的动画形式，-1不开启
                                content: $('.layer-addKind'),
                                skin: "skin-searchMore",
                                yes: function (index) {
                                    var text = public.fn_clearSpace($(
                                        '.layer-addKind .scm-input'
                                    ).val(), 'g')
                                    layer.close(index)
                                    if (text) {
                                        var str =
                                            '<li><label class="mycheckradio"><em></em>' +
                                            text + '</label></li>'
                                        $(".radio-list ul").append(str)
                                    }
                                }
                            })
                        });
                        // 添加品名
                        $(document).on("click", ".btn-addName", function () {
                            layer.open({
                                type: 1, //page层
                                area: ['560px', ''],
                                title: '添加检化验项目',
                                shadeClose: false,
                                btn: ['保存', '取消'],
                                shade: 0.01, //遮罩透明度
                                moveType: 1, //拖拽风格，0是默认，1是传统拖动
                                shift: -1, //0-6的动画形式，-1不开启
                                content: $('.layer-addName'),
                                skin: "skin-searchMore skin-overflow",
                                yes: function () {
                                    $('.layer-add').find('form').submit();
                                }
                            })
                        });
                    },
                    bootstrapTable: function () {
                        page.$table.bootstrapTable({
                            pagination: true, //在表格底部显示分页工具栏
                            pageSize: 50,
                            pageNumber: 1,
                            pageList: [10, 25, 50, 100],
                            height: this.getHeight(),
                            showFooter: false,
                            showColumns: false,
                            showRefresh: false,
                            //                    showToggle:true,
                            search: false,
                            //                    showPaginationSwitch:true,
                            // detailView: true,
                            // detailFormatter: this.showChild,
                            // onExpandRow: this.expandRow,
                            // onCollapseRow: this.collapseRow,
                            locales: 'zh-CN',

                            uniqueId: "id",
                            fixedColumns: true,
                            url: '../data/warrantybook/tablelist-data.json',
                            sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）

                            columns: [{
                                "field": "n0",
                                "title": "状态",
                            }, {
                                "field": "n1",
                                "title": "显示名称",

                            }, {
                                "field": "n2",
                                "title": "字段名称",
                            }, {
                                "field": "n3",
                                "title": "值类型",

                            }, {
                                "field": "n4",
                                "title": "精度",

                            }, {
                                "field": "n5",
                                "title": "创建人",

                            }, {
                                "field": "n6",
                                "title": "创建时间",

                            }]
                        });
                    },
                    // 表格高度
                    getHeight: function () {
                        var height = public.fn_tableHeight()
                        return $(window).height() - height;
                    },
                    //获取选中行数据
                    fn_getTrData: function () {
                        $(document).on('click', '.box-tableTr .table tbody>tr', function () {
                            var id = $(this).closest('tr').attr('data-uniqueid');
                            if ($(this).hasClass('active')) {
                                var data = page.$table.bootstrapTable(
                                    'getRowByUniqueId', id); //获取选中行的数据
                                console.log(data);

                            }

                        })

                    },
                   

                }
                page.init();
            })

        })
    </script>
</body>

</html>